$("#Switchbox", window.parent.parent.document).on("click", function () {
    ModeSwitch.modeSwitch();
    commonbgcolor();
    markbgcolor();
})

//自适应高度(iframe加载完毕后调用)
function infoiframeOn() {
    var iframeObj = document.getElementById('darkMode');

    $('#personal_info', window.parent.document).css('height', iframeObj.scrollHeight);

    setTimeout(() => {
        window.parent.iframeOn('homepage');
    })
}

$.ajax({
    sync: false,
    type: 'GET',
    dataType: 'json',
    url: 'https://gitee.com/api/v5/repos/' + giteeID + '/mweb/contents/homepage.html',
    data: {
        access_token: '6e161c7dacbd1a59136a8c05d40cff00',
    },
    success: function (result) {
        var data = utf8to16(window.atob(result.content));

        document.getElementById('darkMode').innerHTML = data.match(/<[\s]*section[\s]+class[\s]*=[\s]*"ct-body"[\s]*>.*<[\s]*[\/][\s]*section[\s]*>/gs)[0].replaceAll('media', 'https://gitee.com/' + giteeID + '/mweb/raw/master/media').replaceAll('<img src=', '<img onload="iframeOn("infohomepage")" src=').replaceAll('class="title"', '');
        infoiframeOn();
        $('#personal_info', window.parent.document).css('height', $('.ct-body').Height)
    }
})